package com.icloud.common.core.api;

public enum ResultCode implements IErrorCode {

    //操作成功
    SUCCESS(200, "success"),

    //操作失败
    FAILED(999, "failed"),
    // 系统错误
    SYSTEM_ERROR(1000, "system_error"),
    //参数检验失败
    VALIDATE_FAILED(20001, "validate_failed"),
    // JWT解析TOKEN失败
    JWT_PARSE_FAILED(20002, "jwt_parse_failed"),
    //Token过期
    TOKEN_EXPIRE(20003, "token_expire"),
    //暂未登录或TOKEN无效
    UNAUTHORIZED(20004, "unauthorized"),
    //没有相关权限
    FORBIDDEN(20005, "forbidden"),
    //用于刷新的Token 过期
    REFRESH_TOKEN_EXPIRE(20006, "refresh_token_expire"),
    //用户名或密码错误
    USERNAME_OR_PASSWORD_ERROR(20007, "username_or_password_error"),
    //重复点赞
    REPETITION_UPVOTE(20008,"repetition_upvote"),
    //用户名或密码不能为空
    USERNAME_OR_PASSWORD_CAN_NOT_BE_EMPTY(20009,"username_or_password_can_not_be_empty"),
    //数据已存在
    DATA_EXISTS(20010,"data_exists"),
    //数据不存在
    DATA_NOT_EXISTS(20011,"data_not_exists"),
    //用户名重复
    USERNAME_REPETITION(20012,"username_repetition"),
    // 无效的邀请码
    INVALIDATE_INVITE_CODE(20013,"invalidate_invite_code"),
    // 生成钱包失败
    FAILED_GENERATE_WALLET(20014,"failed_generate_wallet"),
    //两次输入密码不一致
    PASSWORD_ENTERED_TWICE_NOT_MATCH(20015, "password_entered_twice_not_match"),
    //红包发送金额必须大于0
    RED_PACKET_AMOUNT_NOT_LTE_ZERO(20016,"red_packet_amount_not_lte_zero"),
    //红包数量不能为空
    RED_PACKET_SIZE_NOT_NULL(20017,"red_packet_size_not_null"),
    //红包领取人不能为空
    RED_PACKET_TO_USER_NOT_NULL(20018,"red_packet_to_user_not_null"),
    //群id不能为空
    RED_PACKET_CHAT_ID_NOT_NULL(20019,"red_packet_chat_id_not_null"),
    // 标题必填
    REQUIRED_TITLE(20020, "required_title"),
    // 资讯Id必填
    REQUIRED_INFOMATION_ID(20021, "required_infomation_id"),
    // 图片地址必填
    REQUIRED_IMG_URL(20022, "required_img_url"),
    // 上传图片太大
    FILE_UPLOAD_IMG_TOO_LARGE(20023, "file_upload_img_too_large"),
    // 云平台S3配置错误
    CLOUD_S3_ERROR(20024, "cloud_s3_error"),
    // 文件上传错误
    FILE_UPLOAD_ERROR(20025, "file_upload_error"),
    // 参数CryptoCurrency取值异常
    ILLEGAL_CRYPTO_CURRENCY(20026, "illegal_crypto_currency"),
    // 参数Handle取值异常
    ILLEGAL_HANDLE_STATE(20027, "illegal_handle_state"),
    // 账户地址必填
    REQUIRED_ACCOUNT_ADDRESS(20028, "required_account_address"),
    // 地址无关联的客户
    NOT_EXIST_ADDRESS_CUSTOMER(20029, "not_exist_address_customer"),
    // 钱包不存在
    NOT_EXIST_WALLET(20030, "not_exist_wallet"),
    // 交易金额必填
    REQUIRED_TX_AMOUNT(20031, "required_tx_amount"),
    // 客户不存在
    NOT_EXIST_CUSTOMER(20032, "not_exist_customer"),
    // 客户已被封号
    STOPPED_CUSTOMER(20033, "stopped_customer"),
    // 交易密码不存在
    NOT_EXIST_TX_PASSWORD(20034, "not_exist_tx_password"),
    // 地址必填
    REQUIRED_ADDRESS(20035, "required_address"),
    // 地址格式错误
    ADDRESS_FORMAT_ERROR(20036, "address_format_error"),
    // 交易金额错误
    TX_AMOUNT_ERROR(20037, "tx_amount_error"),
    // 余额不足
    INSUFFICIENT_BALANCE(20038, "insufficient_balance"),
    // 交易密码必填
    REQUIRED_TX_PASSWORD(20039, "required_tx_password"),
    // 谷歌验证码必填
    REQUIRED_GOOGLE_VERIFY_CODE(20040, "required_google_verify_code"),
    // 交易密码错误
    TX_PASSWORD_ERROR(20041, "tx_password_error"),
    // 谷歌验证码错误
    GOOGLE_VERIFY_CODE_ERROR(20042, "google_verify_code_error"),
    // 交易失败
    TX_FAILED(20043, "tx_failed"),
    // 提现金额超过限额
    WITHDRAW_AMOUNT_EXCEEDS_MAX(20044, "withdraw_amount_exceeds_max"),
    // 订单编号必填
    NOT_EXIST_ORDER_NO(20045, "not_exist_order_no"),
    // 订单不存在
    NOT_EXIST_ORDER(20046, "not_exist_order"),
    // 接受标志必填
    REQUIRED_ACCEPT(20047, "required_accept"),
    // 禁止访问
    CANNOT_ACCESS(20048, "cannot_access"),
    // 订单项不存在
    NOT_EXIST_ORDER_ITEM(20049, "not_exist_order_item"),
    // 订单的资金流水不存在
    NOT_EXIST_WALLET_JOURNAL(20050, "not_exist_wallet_journal"),
    // 账号已禁用
    ACCOUNT_DISABLED(20051, "account_disabled"),
    // 钱包生成失败
    GENERATE_WALLET_FAILED(20052, "generate_wallet_failed"),
    // 合约地址必填
    REQUIRED_CONTRACT_ADDRESS(20053, "required_contract_address"),
    // 禁止分享
    CANNOT_TRANSMIT(20054, "cannot_share"),
    // 所有人不可评论
    DISCUSSION_NO(20055, "discussion_no"),
    //红包数量必须为1
    RED_PACKET_NUMBER_MUST_BE_ONE(20056,"red_packet_number_must_be_one"),
    //你不能领取该红包
    YOU_CANNOT_CLAIM_THE_RED_PACKET(20057,"you_cannot_claim_the_red_packet"),
    //红包已失效
    THE_RED_PACKET_IS_INVALID(20058,"the_red_packet_is_invalid"),
    //红包已领取完
    THE_RED_PACKET_HAS_BEEN_COLLECTED(20059,"the_red_packet_has_been_collected"),
    // 我关注的才能评论
    FOLLOWED_CAN_COMMENT(20060,"followed_can_comment"),
    // 关注我的才能评论
    FOLLOW_ME_CAN_COMMENT(20061,"follow_me_can_comment"),
    // 已被禁言
    HAS_BEEN_BANNED(20062,"has_been_banned"),
    ;

    private final long code;
    private final String message;

    ResultCode(long code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ResultCode byCode(long code) {
        for (ResultCode e: ResultCode.values()) {
            if (e.code==code) {
                return e;
            }
        }
        return null;
    }

    public long getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
